home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Universal_2106383172008.psc / DLL Source / Plugin.cpp next >
C/C++ Source or Header  |  2008-02-13  |  5KB  |  152 lines

  1.  
  2. /* 
  3. ** PlugIn.cpp
  4. ***************************************************************************************************/
  5.  
  6. #define WINVER         0x0501
  7. #define _WIN32_WINNT   WINVER
  8. #define _WIN32_WINDOWS WINVER
  9.  
  10. #include <windows.h>
  11. #include <stdio.h>
  12.  
  13. typedef LONG (__stdcall * _Callback)(LONG nValue);
  14.  
  15. CHAR   szPath[MAX_PATH];
  16. CHAR * szFileName;
  17.  
  18. /*
  19. ** dll entry point
  20. ***************************************************************************************************/
  21. extern "C" BOOL WINAPI _DllMainCRTStartup(HMODULE  hModule, DWORD dwReason, LPVOID  lpreserved)
  22. {
  23.     if (dwReason == DLL_PROCESS_ATTACH)
  24.     {
  25.       //Get the full path of this module
  26.       szFileName = szPath + GetModuleFileNameA(hModule, szPath, MAX_PATH);
  27.  
  28.       while (szFileName > szPath)
  29.          if (*(--szFileName) == '\\') 
  30.             break;
  31.  
  32.       *(szFileName++) = 0;
  33.     }
  34.  
  35.     return TRUE;
  36. }
  37.  
  38. /*
  39. ** MyFunc1, dll ordinal #1
  40. ***************************************************************************************************/
  41. LONG __stdcall MyFunc1(LONG nParam1, LONG nParam2, HWND hWndParent)
  42. {
  43.    CHAR szBuf[512];
  44.    CHAR szCap[256];
  45.  
  46.    wsprintfA(szBuf, "Plugin path:\t%s\nPlugin file:\t%s\nFunction name:\tMyFunc1\nParameter #1:\t%d\nParameter #2:\t%d\n\nClick any button to continue.", szPath, szFileName, nParam1, nParam2);
  47.    wsprintfA(szCap, "%s - MyFunc1", szFileName);
  48.  
  49.    return MessageBoxA(hWndParent, szBuf, szCap, MB_ABORTRETRYIGNORE);
  50. }
  51.  
  52. /*
  53. ** MyFunc2, dll ordinal #2
  54. ***************************************************************************************************/
  55. LONG __stdcall MyFunc2(LONG nParam1, LONG nParam2, HWND hWndParent)
  56. {
  57.    CHAR szBuf[512];
  58.    CHAR szCap[256];
  59.  
  60.    wsprintfA(szBuf, "Plugin path:\t%s\nPlugin file:\t%s\nFunction name:\tMyFunc2\nParameter #1:\t%d\nParameter #2:\t%d\n\nClick any button to continue.", szPath, szFileName, nParam1, nParam2);
  61.    wsprintfA(szCap, "%s - MyFunc2", szFileName);
  62.  
  63.    return MessageBoxA(hWndParent, szBuf, szCap, MB_ABORTRETRYIGNORE);
  64. }
  65.  
  66. /*
  67. ** MyCallback, dll ordinal #3
  68. ***************************************************************************************************/
  69. LONG __stdcall MyCallback(_Callback fnCallback)
  70. {
  71.    for (int i=1; i<=100; i++) //Plugin_1.plugin
  72. // for (int i=100; i>0; i--)  //Plugin_2.plugin
  73.    {
  74.       Sleep(100);
  75.  
  76.       if (fnCallback(i) == 0)
  77.          break;
  78.    }
  79.  
  80.    return 1;
  81. }
  82.  
  83. /*
  84. ** MyShape, dll ordinal #4
  85. ***************************************************************************************************/
  86. LONG __stdcall MyShape(HWND hWnd, HDC hdc)
  87. {
  88.    RECT   rc;
  89.    HBRUSH hbrOld, hbrNew;
  90.    
  91.    GetClientRect(hWnd, &rc);
  92.  
  93.    rc.left = 8;
  94.    rc.top = 8;
  95.    rc.right = rc.right - 8;
  96.    rc.bottom = rc.bottom - 46;
  97.  
  98.    hbrNew = CreateSolidBrush(RGB(0, 128, 0));      //Plugin_1.plugin
  99. // hbrNew = CreateSolidBrush(RGB(128, 0, 0));      //Plugin_2.plugin
  100.  
  101.    hbrOld = (HBRUSH) SelectObject(hdc, hbrNew);
  102.  
  103.    Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom);           //Plugin_1.plugin
  104. // RoundRect(hdc, rc.left, rc.top, rc.right, rc.bottom, 8, 8);   //Plugin_2.plugin
  105.  
  106.    SelectObject(hdc, hbrOld);
  107.    DeleteObject(hbrNew);
  108.  
  109.    return 0;
  110. }
  111.  
  112. /*
  113. ** Fast1, dll ordinal #5
  114. ***************************************************************************************************/
  115. LONG __fastcall Fast1(LONG nParam1)
  116. {
  117.    CHAR szBuf[512];
  118.    CHAR szCap[256];
  119.  
  120.    wsprintfA(szBuf, "Plugin path:\t%s\nPlugin file:\t%s\nFunction name:\tFast1\nParameter #1:\t%d\n\n\nClick any button to continue.", szPath, szFileName, nParam1);
  121.    wsprintfA(szCap, "%s - Fast1", szFileName);
  122.  
  123.    return MessageBoxA(0, szBuf, szCap, MB_ABORTRETRYIGNORE);
  124. }
  125.  
  126. /*
  127. ** Fast2, dll ordinal #6
  128. ***************************************************************************************************/
  129. LONG __fastcall Fast2(LONG nParam1, LONG nParam2)
  130. {
  131.    CHAR szBuf[512];
  132.    CHAR szCap[256];
  133.  
  134.    wsprintfA(szBuf, "Plugin path:\t%s\nPlugin file:\t%s\nFunction name:\tFast2\nParameter #1:\t%d\nParameter #2:\t%d\n\nClick any button to continue.", szPath, szFileName, nParam1, nParam2);
  135.    wsprintfA(szCap, "%s - Fast2", szFileName);
  136.  
  137.    return MessageBoxA(0, szBuf, szCap, MB_ABORTRETRYIGNORE);
  138. }
  139.  
  140. /*
  141. ** Fast3, dll ordinal #7
  142. ***************************************************************************************************/
  143. LONG __fastcall Fast3(LONG nParam1, LONG nParam2, LONG nParam3)
  144. {
  145.    CHAR szBuf[512];
  146.    CHAR szCap[256];
  147.  
  148.    wsprintfA(szBuf, "Plugin path:\t%s\nPlugin file:\t%s\nFunction name:\tFast3\nParameter #1:\t%d\nParameter #2:\t%d\nParameter #3:\t%d\n\nClick any button to continue.", szPath, szFileName, nParam1, nParam2, nParam3);
  149.    wsprintfA(szCap, "%s - Fast3", szFileName);
  150.  
  151.    return MessageBoxA(0, szBuf, szCap, MB_ABORTRETRYIGNORE);
  152. }